<?php

require_once('Classes/Datasources/Filters/Filter_Not.php');
require_once('Classes/Datasources/Filters/Filter_TableStartsWith.php');

Mock::generate( 'Filter_TableStartsWith' );

class Test_Filter_Not extends UnitTestCase {
    
    function test_ShouldIncludeTableWillReturnTrueIfThePassedFilterReturnsFalse() {

		$sTableName = 'TableThing';

		$oFilterReturnsFalse = &new MockFilter_TableStartsWith();
		$oFilterReturnsFalse->setReturnValue( 'ShouldIncludeTable', false );
		$oFilterReturnsFalse->expectOnce( 'ShouldIncludeTable', array( $sTableName ) );

    	$oGate = new Filter_Not( $oFilterReturnsFalse );
        $this->assertTrue(  $oGate->ShouldIncludeTable( $sTableName ) );
    }
    
    function test_ShouldIncludeTableWillReturnFalseIfThePassedFilterReturnsTrue() {

		$sTableName = 'TableThing';

		$oFilterReturnsTrue = &new MockFilter_TableStartsWith();
		$oFilterReturnsTrue->setReturnValue( 'ShouldIncludeTable', true );
		$oFilterReturnsTrue->expectOnce( 'ShouldIncludeTable', array( $sTableName ) );

    	$oGate = new Filter_Not( $oFilterReturnsTrue );
        $this->assertFalse(  $oGate->ShouldIncludeTable( $sTableName ) );
    }

    function test_ShouldIncludeTableWillReturnTrueIfThePassedFilterReturnsNull() {

		$sTableName = 'TableThing';

		$oFilterReturnsNull = &new MockFilter_TableStartsWith();
		$oFilterReturnsNull->setReturnValue( 'ShouldIncludeTable', null );
		$oFilterReturnsNull->expectOnce( 'ShouldIncludeTable', array( $sTableName ) );

    	$oGate = new Filter_Not( $oFilterReturnsNull );
        $this->assertTrue(  $oGate->ShouldIncludeTable( $sTableName ) );
    }

}

?>
